package com.epam.android.mailcomponent.contacts;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.CheckedTextView;
import android.widget.LinearLayout;

public class ContactsListView extends LinearLayout {
	
	private static final String NAME_EMAIL_SEPARATOR = " : ";

	private Contact contact = null;
	private CheckedTextView checkedTextView = null;

	public ContactsListView(Context context, AttributeSet attrs) {
		super(context, attrs);
		checkedTextView = (CheckedTextView) findViewById(android.R.id.text1);
	}

	@Override
	protected void onFinishInflate() {
		super.onFinishInflate();
		checkedTextView = (CheckedTextView) findViewById(android.R.id.text1);
	}

	public Contact getContact() {
		return contact;
	}

	public void setContact(Contact contact) {
		this.contact = contact;
		checkedTextView.setChecked(contact.isChecked());
		checkedTextView.setText(contact.getName()
				+ NAME_EMAIL_SEPARATOR + contact.getEmail());
	}
}
